﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;

namespace DoAn
{
    public partial class frcapnhatNV : Form
    {
        public frcapnhatNV()
        {
            InitializeComponent();
        }

        public frcapnhatNV(string MaNV)
            : this()
        {
            NhanVienDTO nvDTO = new NhanVienDTO();
            NhanVienBUS nvBUS = new NhanVienBUS();
            nvDTO = nvBUS.Laynvtheoma(MaNV);
            txtMaNV.Text = nvDTO.MaNV;
            txtTenNV.Text = nvDTO.TenNV;
            txtDienThoai.Text = nvDTO.DienThoai.ToString();
            txtNgaySinh.Text = nvDTO.NgaySinh.ToString();
            txtGioiTinh.Text = nvDTO.GioiTinh.ToString();
            txtMaBoPhan.Text = nvDTO.MaBoPhan.ToString();
            txtDiaChi.Text = nvDTO.DiaChi.ToString();
            txtLuong.Text = nvDTO.Luong.ToString();
        }

        private void btnCapnhat_Click(object sender, EventArgs e)
        {
            NhanVienDTO cnDTO = new NhanVienDTO();
            cnDTO.MaNV = txtMaNV.Text.Trim();
            cnDTO.TenNV = txtTenNV.Text.Trim();
            cnDTO.DienThoai = txtDienThoai.Text.Trim();
            cnDTO.NgaySinh = DateTime.Parse(txtNgaySinh.Text.ToString());
            cnDTO.GioiTinh = int.Parse(txtGioiTinh.Text.ToString());
            cnDTO.MaBoPhan = int.Parse(txtMaBoPhan.Text.ToString());
            cnDTO.DiaChi = txtDiaChi.Text.Trim();
            cnDTO.Luong = int.Parse(txtLuong.Text.ToString());

            NhanVienBUS nvBUS = new NhanVienBUS();
            nvBUS.Capnhatnv(cnDTO);
            Close();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

    }
}
